import React, { useState, useE } from 'react'
import axios from 'axios'
import { Tabs, Space, TextArea, Button } from 'antd-mobile'
import { useNavigate, useSearchParams } from 'react-router-dom'
export default function Newcf() {
    let navigate = useNavigate()
    let [search] = useSearchParams()
    let [name, setName] = useState('')
    let [age, setAge] = useState('')
    let [sex, setSex] = useState('')
    let [zd, setZd] = useState('')
    let [yj, setYj] = useState('')
    let [dt, setDt] = useState('')
    let [ks, setKs] = useState('')
    let top = () => {
        navigate(-1)
    }
    let save = async() => {
        console.log(64);
        let obj = {
            ptname: name,
            ptage: age,
            ptsex: sex,
            dname: dt,
            ks: ks,
            zd: zd,
            yj: yj,

        }
        console.log(obj);
        let {data}=await axios.post('http://127.0.0.1:3000/mxd_addcf',obj)
        console.log(data);
        navigate('/gg/ks')
        


    }
    return (
        <div id='newcf'>
            <div className="top">
                <p>
                    <span>
                        <svg onClick={top} style={{ width: '30px', height: '35px', position: 'absolute', marginLeft: '5px' }} t="1724675809513" className="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2590" width="200" height="200"><path d="M670.6 861.6c-7.6 0-15.1-2.9-20.9-8.6L329.4 532.7c-11.6-11.5-11.6-30.3 0-41.8l320.2-320.2c5.8-5.8 13.3-8.6 20.9-8.6 7.5 0 15.1 2.9 20.9 8.6 11.5 11.5 11.5 30.2 0 41.8L392 511.8l299.4 299.4c11.5 11.6 11.5 30.3 0 41.8-5.7 5.7-13.3 8.6-20.8 8.6z" fill="#2c2c2c" p-id="2591"></path></svg>
                    </span>
                    <span style={{ marginLeft: '35px', marginTop: '10px', lineHeight: '33px', fontSize: '20px' }}>新建常用处方</span>

                </p>
                <hr />
            </div>
            <div className="big">
                <p>患者姓名：
                    <input className='name1' onChange={(e) => { setName(e.target.value) }} value={name} type="text" />
                </p>
                <p>年龄：
                    <input className='name1' onChange={(e) => { setAge(e.target.value) }} value={age} type="text" />岁
                </p>
                <p>性别：
                    <input onClick={(e) => { setSex(e.target.value) }} className='name1' name='sex' value={true} type="radio" />男
                    <input onClick={(e) => { setSex(e.target.value) }} className='name1' name='sex' value={false} type="radio" />女


                </p>
            </div>
            <div className="big2">
                <p><label htmlFor="">初步诊断：</label><br />
                    <textarea className='area1' onChange={(e) => { setZd(e.target.value) }} cols={30} rows={2} value={zd} name="" id=""></textarea>
                </p>
                <p><label htmlFor="">处理意见：</label><br />
                    <textarea className='area1' onChange={(e) => { setYj(e.target.value) }} cols={30} rows={4} value={yj} name="" id=""></textarea>
                </p>
            </div>
            <div className="big3">
                <span className='rp'>Rp</span>
                <div className="sml">

                </div>

                <Button onClick={() => { navigate('/gg/addy') }} style={{ width: '200px', marginLeft: '100px', marginTop: '25px', marginBottom: '20px' }} shape='rounded' size='large' color='primary' fill='outline'>
                    新增药品
                </Button>
            </div>
            <div className="big4">
                <p>处方医师：

                    <input className='name1' onChange={(e) => { setDt(e.target.value) }} value={dt} type="text" />

                </p>
                <p>科室：

                    <input className='name1' onChange={(e) => { setKs(e.target.value) }} value={ks} type="text" />

                </p>

            </div>
            <div className="bc">
                <Button onClick={save} style={{ width: '300px', marginLeft: '50px', marginTop: '20px' }} shape='rounded' color='primary' >
                    保存
                </Button>
            </div>
        </div>
    )
}
